import { request } from '../request';

export const globalCaptcha = process.env.API + '/global/captcha';
export const globalCaptchaCheck = process.env.API + '/global/captcha-check';

export function globalDelImg(params: {
  /*图片url */
  href: string;
}) {
  return request({
    url: '/global/del-img',
    method: 'post',
    data: params,
  });
}

/* 关注用户 */
export function globalFollowUser(param: { userId: string }) {
  return request<boolean>({
    url: '/global/follow-user',
    method: 'post',
    data: param,
  });
}

/* 关注标签 */
export function globalFollowTag(param: { tagId: string }) {
  return request<boolean>({
    url: '/global/follow-tag',
    method: 'post',
    data: param,
  });
}

/* 关注标签 */
export function globalFollowTopic(param: { topicId: string }) {
  return request<boolean>({
    url: '/global/follow-topic',
    method: 'post',
    data: param,
  });
}

export function globalIsLogin() {
  return request<boolean>({
    url: '/global/is-login',
    method: 'get',
  });
}

/* 上传Base64格式图片 */
export function globalUploadBase64Img(files: string) {
  return request<Api.FileInfo>({
    url: '/global/upload-base64-img',
    method: 'post',
    data: { data: files },
  });
}

/* 上传图片 */
export function globalUploadImg(files: FormData) {
  return request<Api.FileInfo>({
    url: '/global/upload-img',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    data: files,
  });
}
